package com.social.pojo;


import java.io.Serializable;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.social.utils.annotation.EnumValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;

import javax.validation.constraints.*;

/**
 * 信访
 * @TableName petition
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("petition")
@ApiModel("信访信息")
public class Petition implements Serializable {
    /**
     * 信访编号
     */
    @ApiModelProperty("信访编号")
    @TableId(value = "pe_id",type = IdType.AUTO)
    private Long peId;

    /**
     * 信访标题
     */
    @NotBlank(message = "标题为必填")
    @Size(min=5,max = 25,message = "内容必须在[5,25]字")
    @ApiModelProperty("信访标题")
    @TableField("pe_title")
    private String peTitle;

    /**
     * 信访类别
     */
    @TableField("pe_address")
    private String peAddress;

    /**
     * 信访内容
     */
    @NotBlank(message = "内容为必填")
    @Size(min=10,max = 500,message = "内容必须在[10,500]字")
    @ApiModelProperty("信访内容")
    @TableField("pe_content")
    private String peContent;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @TableField("creat_time")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime creatTime;

    /**
     * 是否同意公开
     */
    @EnumValue(intValues = {0,1},message = "只能填入0或者1")
    @ApiModelProperty("是否同意公开")
    @TableField("is_public")
    private Integer isPublic;

    /**
     * 信访状态
0 已提交，待审核
1 审核中
2 已审核
-1 删除、撤销
     */
    @ApiModelProperty("信访状态 0 已提交，待审核\n" +
            "1 审核中\n" +
            "2 已办结\n" +
            "-1 删除、撤销")
    @TableField("pe_status")
    private Integer peStatus;
    /**
     * 用户文件上传
     */
    @ApiModelProperty("用户文件上传")
    @TableField("filename")
    private String filename;
    /**
     * 用户id
     */
    @ApiModelProperty("用户id")
    @TableField("user_id")
    private Long userId;

    @Transient
    @TableField(exist = false,value = "code")
    private String code;

    @ApiModelProperty("信访地址")
    @Transient
    @TableField(exist = false,value = "selectedOptions")
    private String[]  selectedOptions;

    @TableField("findcode")
    @ApiModelProperty("信访查询码")
    private String findCode;

    @TableField("reply")
    @ApiModelProperty("信访回复")
    private String reply;

    private static final long serialVersionUID = 1L;
}


